//
//  ZTimeOutOrderCell.m
//  DistributorAB
//
//  Created by LZY on 2019/10/16.
//  Copyright © 2019 主事丫环. All rights reserved.
//

#import "ZTimeOutOrderCell.h"

@interface ZTimeOutOrderCell ()
@property (nonatomic, strong) UILabel *lblDate;//日期
@property (nonatomic, strong) UILabel *lblState;//状态
@property (nonatomic, strong) UILabel *lblServe;//服务类型
@property (nonatomic, strong) UILabel *lblType;//电器品类
@property (nonatomic, strong) UILabel *lblAddress;//所在地区

@end

@implementation ZTimeOutOrderCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupViewAction];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

#pragma mark - 界面布局
- (void)setupViewAction{
    self.contentView.backgroundColor = kColorWithHex(0xf2f2f2);
    
    UIView *viewBg = [[UIView alloc] initWithFrame:CGRectMake(0, 10, kScreen_Width, 163)];
    viewBg.backgroundColor = kColorWithHex(0xffffff);
    [self.contentView addSubview:viewBg];
    
    _lblDate = [UILabel new];
    _lblDate.font = [UIFont systemFontOfSize:12];
    _lblDate.textColor = kColorWithHex(0x999999);
    [viewBg addSubview:_lblDate];
    [_lblDate mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(viewBg.mas_leading).offset(16);
        make.top.equalTo(viewBg.mas_top).offset(9);
        make.height.mas_equalTo(17);
    }];
    
    _lblState = [UILabel new];
    _lblState.font = [UIFont systemFontOfSize:11];
    _lblState.textColor = kColorWithHex(0xf88b1f);
    [viewBg addSubview:_lblState];
    [_lblState mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(viewBg.mas_trailing).offset(-16);
        make.centerY.equalTo(self.lblDate.mas_centerY);
        make.height.mas_equalTo(17);
    }];
    
    UILabel *lblNoticeServe = [UILabel new];
    lblNoticeServe.text = @"服务类型:";
    lblNoticeServe.font = [UIFont systemFontOfSize:14];
    lblNoticeServe.textColor = kColorWithHex(0x666666);
    [viewBg addSubview:lblNoticeServe];
    [lblNoticeServe mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.lblDate.mas_leading);
        make.top.equalTo(self.lblDate.mas_bottom).offset(8);
        make.height.mas_equalTo(20);
    }];
    
    _lblServe = [UILabel new];
    _lblServe.font = [UIFont boldSystemFontOfSize:14];
    _lblServe.textColor = kColorWithHex(0x333333);
    [viewBg addSubview:_lblServe];
    [_lblServe mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(lblNoticeServe.mas_centerY);
        make.leading.equalTo(lblNoticeServe.mas_trailing).offset(10);
        make.height.mas_equalTo(20);
    }];
    
    UILabel *lblNoticeType = [UILabel new];
    lblNoticeType.text = @"电器品类:";
    lblNoticeType.font = [UIFont systemFontOfSize:14];
    lblNoticeType.textColor = kColorWithHex(0x666666);
    [viewBg addSubview:lblNoticeType];
    [lblNoticeType mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.lblDate.mas_leading);
        make.top.equalTo(lblNoticeServe.mas_bottom).offset(6);
        make.height.mas_equalTo(20);
    }];
    
    _lblType = [UILabel new];
    _lblType.font = [UIFont boldSystemFontOfSize:14];
    _lblType.textColor = kColorWithHex(0x333333);
    [viewBg addSubview:_lblType];
    [_lblType mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(lblNoticeType.mas_centerY);
        make.leading.equalTo(lblNoticeType.mas_trailing).offset(10);
        make.height.mas_equalTo(20);
    }];
    
    UILabel *lblNoticeAddress = [UILabel new];
    lblNoticeAddress.text = @"所在地区:";
    lblNoticeAddress.font = [UIFont systemFontOfSize:14];
    lblNoticeAddress.textColor = kColorWithHex(0x666666);
    [viewBg addSubview:lblNoticeAddress];
    [lblNoticeAddress mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.lblDate.mas_leading);
        make.trailing.equalTo(lblNoticeType.mas_trailing);
        make.top.equalTo(lblNoticeType.mas_bottom).offset(6);
        make.height.mas_equalTo(20);
    }];
    
    _lblAddress = [UILabel new];
    _lblAddress.font = [UIFont boldSystemFontOfSize:14];
    _lblAddress.textColor = kColorWithHex(0x333333);
    [viewBg addSubview:_lblAddress];
    [_lblAddress mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(lblNoticeAddress.mas_centerY);
        make.leading.equalTo(lblNoticeAddress.mas_trailing).offset(10);
        make.trailing.equalTo(viewBg.mas_trailing).offset(-16);
        make.height.mas_equalTo(20);
    }];
    
    UIView *viewLine = [UIView new];
    viewLine.backgroundColor = kColorWithHex(0xf2f2f2);
    [viewBg addSubview:viewLine];
    [viewLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.equalTo(viewBg);
        make.top.equalTo(lblNoticeAddress.mas_bottom).offset(10);
        make.height.mas_equalTo(1);
    }];
    
    UILabel *lblNoticeCheck = [UILabel new];
    lblNoticeCheck.text = @"查看详情";
    lblNoticeCheck.font = [UIFont boldSystemFontOfSize:14];
    lblNoticeCheck.textColor = kColorWithHex(0x666666);
    [viewBg addSubview:lblNoticeCheck];
    [lblNoticeCheck mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.lblDate.mas_leading);
        make.top.equalTo(viewLine.mas_bottom).offset(12);
        make.height.mas_equalTo(20);
    }];
    
    UIImageView *ivArrow = [UIImageView new];
    ivArrow.image = imgname(@"arrow_right_icon");
    [viewBg addSubview:ivArrow];
    [ivArrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(lblNoticeCheck.mas_centerY);
        make.trailing.equalTo(viewBg.mas_trailing).offset(-16);
        make.size.mas_equalTo(CGSizeMake(8, 16));
    }];
    
}
#pragma mark - 数据更新
- (void)setModel:(ZTimeOutOrderModel *)model{
    if (model) {
        _model = model;
        _lblDate.text = model.create_time;
        _lblServe.text = model.service_name;
        _lblType.text = [NSString stringWithFormat:@"%@ %@",model.firstName,model.secondName];
        _lblAddress.text = model.user_address;
        NSInteger delState = [model.delstate integerValue];
        if (delState == 0) {
            _lblState.text = @"未处理";
        }else if (delState == 1){
            _lblState.text = @"处理中";
        }else if (delState == 2){
            _lblState.text = @"已处理";
        }
    }
}
+ (CGFloat)cellHeight{
    return 173.0;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
